#!/bin/sh

echo "time: `date` "  >> /var/log/ceph/umount_disk.log
echo $1 >> /var/log/umount_disk.log

disk=`echo $1|grep "disk.status\["|grep "onlien\]"|awk -F '[' '{print $2}'|awk -F ',' '{print $1}'`
echo "disk: $disk" >> /var/log/ceph/umount_disk.log

osdnum=`mount |grep $disk | awk '{print $3}' | awk -F - '{print $2}'`
echo "osdnum: $osdnum" >> /var/log/ceph/umount_disk.log 


service ceph stop osd.${osdnum}
ps -ef | grep osd.${osdnum} | grep -v grep | awk '{print $2}' |  xargs kill -9

osddev=`mount |grep ${disk}1 | awk '{print $3}'`

echo "osddev: $osddev" >> /var/log/ceph/umount_disk.log

systemctl restart systemd-udevd.service

umount -f ${osddev}
ret=$?
echo "umount ${osddev} result is: $ret" >> /var/log/ceph/umount_disk.log

systemctl restart systemd-udevd.service
#systemctl daemon-reload

